home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_319
/
cnewssrc
/
uupc.lzh
/
uupc
/
chdir.c
next >
Wrap
C/C++ Source or Header
|
1990-01-16
|
1KB
|
72 lines
/*
* chdir
*
* Amiga (Manx) Library
*
* $Id: chdir.c,v 1.2 90/01/16 10:24:41 crash Exp Locker: crash $
*/
#ifndef lint
static char RCSid[] = "$Id: chdir.c,v 1.2 90/01/16 10:24:41 crash Exp Locker: crash $";
#endif /* lint */
#include <libraries/dos.h>
#include <exec/memory.h>
#ifdef MCH_AMIGA
# include <functions.h> /* Manx */
#else
# include <proto/exec.h> /* Lattice */
#endif
#ifdef TEST
# include <stdio.h>
#endif
#ifndef NULL
# define NULL 0L
#endif
/*------------------------------------------------------------------*/
/* chdir(path): make path the current directory. Return Ok/Not */
/*------------------------------------------------------------------*/
int chdir(path)
char *path;
{
register struct FileLock *lock;
struct FileLock *oldLock;
#ifdef TEST
fprintf( stderr, "Changing to directory \"%s\"\n\n", path );
#endif
lock = Lock(path, ACCESS_READ);
if (!lock)
return (int) IoErr();
oldLock = CurrentDir(lock);
if (oldLock)
UnLock(oldLock);
return 0;
}
#ifdef TEST
main()
{
char command[108];
FILE *f;
gets(command);
fprintf(stderr, "%d\n", chdir(command));
if (f = fopen("abc", "r")) {
fprintf(stderr, "Opened Ok!\n");
fclose(f);
} else
fprintf(stderr, "Can't open abc\n");
return( NULL );
}
#endif /* TEST */